﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Drawing;
using System.Windows.Forms;
using System.Text;

namespace BlockEngine.Engine.Integration.Windows
{
    class NotificationIcon : Form
    {
        public NotifyIcon Icon = new NotifyIcon();
        private ContextMenu Menu = new ContextMenu();

        public bool Initialized = false;
        public void Initialize()
        {
            Icon.Icon = new System.Drawing.Icon(@"Content\\Integration\\Windows\\BlockEngine.ico");
            Icon.Text = "BlockEngine";
            Icon.Visible = true;
            Initialized = true;
            Icon.ContextMenu = Menu;
            Menu.MenuItems.Add(0, new MenuItem("Toggle Polygon Mode", new System.EventHandler(TogglePolygonMode)));
            Menu.MenuItems.Add(1, new MenuItem("Exit", new System.EventHandler(Exit)));
        }
        protected void TogglePolygonMode(Object sender, System.EventArgs e)
        {
            if (!Network.Client.Wireframe)
                Network.Client.Wireframe = true;
            else
                Network.Client.Wireframe = false;
        }
        protected void Exit(Object sender, System.EventArgs e)
        {
            Environment.Exit(0);
        }

        public void Message(string Message)
        {
            if (!Initialized)
                Initialize();
            Icon.ShowBalloonTip(10, "BlockEngine", Message, ToolTipIcon.Info);
        }
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                this.Icon.Dispose(); //we dispose our tray icon here
            }
            base.Dispose(disposing);
        }
    }
}
